package com.heima.article.controller;

import com.heima.article.service.ApArticleService;
import com.heima.model.common.constants.ArticleConstants;
import com.heima.model.common.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ArticleShowDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("app文章数据管理")
@Slf4j
@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController {

    @Autowired
    private ApArticleService apArticleService;

    /**
     * 文章列表加载
     * @param dto
     * @return
     */
    @ApiOperation("文章列表加载接口")
    @PostMapping("/load/")
    public ResponseResult getList(@RequestBody ArticleHomeDto dto){
        log.info("文章列表加载接口，入参={}",dto);
        return apArticleService.selectLoad(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
    }

    /**
     * 文章列表更多加载
     * @param dto
     * @return
     */
    @ApiOperation("文章列表更多加载接口")
    @PostMapping("/loadmore")
    public ResponseResult getListMore(@RequestBody ArticleHomeDto dto){
        log.info("文章列表更多加载接口，入参={}",dto);
        return apArticleService.selectLoad(dto,ArticleConstants.LOADTYPE_LOAD_MORE);
    }

    /**
     * 文章列表最新加载
     * @param dto
     * @return
     */
    @ApiOperation("文章列表最新加载接口")
    @PostMapping("/loadnew")
    public ResponseResult getListNew(@RequestBody ArticleHomeDto dto){
        log.info("文章列表最新加载接口，入参={}",dto);
        return apArticleService.selectLoad(dto,ArticleConstants.LOADTYPE_LOAD_NEW);
    }

    @GetMapping("/null")
    public ResponseResult getApArticle(ArticleShowDto showDto){
        log.info("回显文章接口，入参={}",showDto);
        return null;
    }

}
